﻿using CatUtils.Utils.Currency.IoUtils;

using CatUtils.Utils.SpecialUtils.View;
using System;
using System.Windows.Forms;

namespace RabbitDownload.WebSite.Konachan.Tag
{
    public partial class KonachanTagControl : UserControl
    {
        public KonachanTagControl()
        {
            InitializeComponent();
            InitView();
        }

        private void InitView()
        {
            comboBox1.SelectedIndex = 0;

            KonachanStaticValue.ExcludeFlag = checkBox1.Checked;
        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            KonachanStaticValue.DownLoadMode = comboBox1.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StartScanner();
        }

        private void StartScanner()
        {
            foreach (string Line in richTextBox1.Lines)
            {
                if (Line == "")
                    continue;

                new KonachanTagScanner().Start(Line.Trim(),//标签

                    textboxOnlyCount3.Text,//评分

                    comboBox1.Text,//模式
                    textboxOnlyCount1.Text, textboxOnlyCount2.Text,//起始结束
                    checkBox1.Checked, checkBox2.Checked);//启用日志和黑名单与否
            }
            MessageHelper.Alert("下载完成！");
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            KonachanStaticValue.ExcludeFlag = checkBox1.Checked;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            new KonachanTagScanner().StartWithFile(FileHelper.SelectFile(),//标签文件

                    textboxOnlyCount3.Text,//评分

                    comboBox1.Text,//模式
                    textboxOnlyCount1.Text, textboxOnlyCount2.Text,//起始结束
                    checkBox1.Checked);//启用日志和黑名单与否
        }
    }
}